<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">

      <el-form-item label="姓名" prop="xm">
        <el-input v-model="queryParams.xm" placeholder="请输入姓名" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="学号" prop="xh">
        <el-input v-model="queryParams.xh" placeholder="请输入学号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>


      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['system:apply:add']">新增1</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['system:apply:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['system:apply:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['system:apply:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="applyList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="姓名" align="center" prop="xm" />
      <el-table-column label="年级" align="center" prop="nj" />
      <el-table-column label="学院" align="center" prop="xy" />
      <el-table-column label="专业" align="center" prop="zy" />
      <el-table-column label="班级" align="center" prop="bj" />
      <el-table-column label="辅导员审核" align="center" prop="fdyqm">
        <template slot-scope="scope">
          <!-- <img  v-if="scope.row.fdyqm" :src="scope.row.zp" width="160px" height="50px"> -->
          <span v-if="scope.row.fdyqm"> 通过</span>
          <span v-else>未审核</span>
        </template>

      </el-table-column>
      <el-table-column label="二级学院审核" align="center" prop="ejxyldqm">
        <template slot-scope="scope">
          <div v-if="scope.row.ejxyldqm">
            <div v-if="scope.row.csdj == '1'">
              一等国家助学金
            </div>
            <div v-if="scope.row.csdj == '2'">
              二等国家助学金
            </div>
            <div v-if="scope.row.csdj == '3'">
              三等国家助学金
            </div>
            <!-- 签名：<img :src="scope.row.ejxyldqm" width="160px" height="50px"> -->

          </div>
          <span v-else>未审核</span>
        </template>

      </el-table-column>
      <el-table-column label="学院意见" align="center" prop="zzdj">
        <template slot-scope="scope">
          <div v-if="scope.row.zzdj">
            <div v-if="scope.row.zzdj == '1'">
              一等国家助学金
            </div>
            <div v-if="scope.row.zzdj == '2'">
              二等国家助学金
            </div>
            <div v-if="scope.row.zzdj == '3'">
              三等国家助学金
            </div>
          </div>
          <div v-else>未审核</div>
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-if="scope.row.step == 1" v-hasPermi="['system:apply:edit']">修改</el-button>

          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-if="scope.row.step == 2" v-hasPermi="['system:apply:edit']">辅导员审核</el-button>

          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-if="scope.row.step == 3" v-hasPermi="['system:apply:edit']">二级学院审核</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-if="scope.row.step == 4" v-hasPermi="['system:apply:edit']">学校意见</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" v-if="scope.row.step == 1"
            @click="handleDelete(scope.row)" v-hasPermi="['system:apply:remove']">删除</el-button>

          <el-button size="mini" type="text" v-if="scope.row.step == 5 || scope.row.step == 1"
            @click="handleUpdate(scope.row)" v-hasPermi="['system:apply:remove']">查看</el-button>

        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />


  </div>
</template>

<script>
import { listApply, getApply, delApply, addApply, updateApply } from "@/api/zxj/apply";
import ImportTable from '../tool/gen/importTable.vue';

export default {
  name: "poverty_Apply",
  data() {

    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      applyList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        step: null,
        xm: null,
        xb: null,
        mz: null,
        zzmm: null,
        xh: null,
        rxsj: null,
        csny: null,
        dh: null,
        nj: null,
        xy: null,
        zy: null,
        bj: null,
        kndj: null,
        knlx: null,
        knlx2: null,
        rkzs: null,
        yzsr: null,
        rjyr: null,
        srly: null,
        jtcy: null,
        sqly: null,
        fdyqm: null,
        fdyqmrq: null,
        ejxyldqm: null,
        ejxyldqmrq: null,
        xsqm: null,
        xsqmrq: null,
        csdj: null,
        zzdj: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listApply(this.queryParams).then(response => {
        this.applyList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        step: null,
        xm: null,
        xb: null,
        mz: null,
        zzmm: null,
        xh: null,
        rxsj: null,
        csny: null,
        dh: null,
        nj: null,
        xy: null,
        zy: null,
        bj: null,
        kndj: null,
        knlx: null,
        knlx2: null,
        rkzs: null,
        yzsr: null,
        rjyr: null,
        srly: null,
        jtcy: null,
        sqly: null,
        fdyqm: null,
        fdyqmrq: null,
        ejxyldqm: null,
        ejxyldqmrq: null,
        xsqm: null,
        xsqmrq: null,
        csdj: null,
        zzdj: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加【请填写功能名称】";
      this.$router.push({ path: "/good/Proverty/proverty_examine" });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {

      const nid = row.id || this.ids;
      this.$router.push({ path: "/good/Proverty/proverty_examine", query: { id: nid } });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateApply(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addApply(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + ids + '"的数据项？').then(function () {
        return delApply(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/apply/export', {
        ...this.queryParams
      }, `apply_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
